﻿using UnityEngine;
using System.Collections;

public class Hud : MonoBehaviour {

	public GameObject screenReady;
	public GameObject screenWinLevel;
	public GameObject screenLoseLife;
	public GameObject screenGameOver;
	public GameObject screenDance;

	public GameObject[] scoreFontSprites;
	public GameObject[] scoreDigits;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		screenReady.SetActive (Tappa.game.state == TappaGame.TappaGameState.Readying);
		screenWinLevel.SetActive (Tappa.game.state == TappaGame.TappaGameState.LevelWin);
		screenLoseLife.SetActive (Tappa.game.state == TappaGame.TappaGameState.LiterallyDying);
		screenGameOver.SetActive (Tappa.game.state == TappaGame.TappaGameState.GameOver);
		screenDance.SetActive (Tip.isdance);

		int ten = 1;
		for (int z = 0; z < scoreDigits.Length; z++) {		
			int score = Score.scoreSmoothed;
			int numeral = (score / ten) % 10;
			ten *= 10;
			Sprite sprite = null;
			if (numeral < scoreFontSprites.Length)
				sprite = scoreFontSprites [numeral].GetComponent<SpriteRenderer> ().sprite;
			if (sprite != null)
				scoreDigits [z].GetComponent<SpriteRenderer> ().sprite = sprite;
		}

	}
}
